package cn.iocoder.yudao.module.bpm.dal.mysql.tohandle;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.bpm.controller.admin.tohandle.flow.vo.BpmHandleFlowExportReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.tohandle.flow.vo.BpmHandleFlowPageReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.tohandle.BpmHandleFlowDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 审批流待办中心——流程flow表 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface BpmHandleFlowMapper extends BaseMapperX<BpmHandleFlowDO> {

    default PageResult<BpmHandleFlowDO> selectPage(BpmHandleFlowPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BpmHandleFlowDO>()
                .eqIfPresent(BpmHandleFlowDO::getExtFlowId, reqVO.getExtFlowId())
                .likeIfPresent(BpmHandleFlowDO::getTitle, reqVO.getTitle())
                .likeIfPresent(BpmHandleFlowDO::getSenderUsername, reqVO.getSenderUsername())
                .likeIfPresent(BpmHandleFlowDO::getSenderName, reqVO.getSenderName())
                .betweenIfPresent(BpmHandleFlowDO::getSendTime, reqVO.getSendTime())
                .betweenIfPresent(BpmHandleFlowDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(BpmHandleFlowDO::getSourceSystemId, reqVO.getSourceSystemId())
                .eqIfPresent(BpmHandleFlowDO::getSourceUrl, reqVO.getSourceUrl())
                .eqIfPresent(BpmHandleFlowDO::getFlowStatus, reqVO.getFlowStatus())
                .betweenIfPresent(BpmHandleFlowDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(BpmHandleFlowDO::getUpdateTime, reqVO.getUpdateTime())
                .eqIfPresent(BpmHandleFlowDO::getCreator, reqVO.getCreator())
                .eqIfPresent(BpmHandleFlowDO::getUpdater, reqVO.getUpdater())
                .eqIfPresent(BpmHandleFlowDO::getDeleted, reqVO.getDeleted())
                .orderByDesc(BpmHandleFlowDO::getId));
    }

    default List<BpmHandleFlowDO> selectList(BpmHandleFlowExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BpmHandleFlowDO>()
                .eqIfPresent(BpmHandleFlowDO::getExtFlowId, reqVO.getExtFlowId())
                .likeIfPresent(BpmHandleFlowDO::getTitle, reqVO.getTitle())
                .likeIfPresent(BpmHandleFlowDO::getSenderUsername, reqVO.getSenderUsername())
                .likeIfPresent(BpmHandleFlowDO::getSenderName, reqVO.getSenderName())
                .betweenIfPresent(BpmHandleFlowDO::getSendTime, reqVO.getSendTime())
                .betweenIfPresent(BpmHandleFlowDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(BpmHandleFlowDO::getSourceSystemId, reqVO.getSourceSystemId())
                .eqIfPresent(BpmHandleFlowDO::getSourceUrl, reqVO.getSourceUrl())
                .eqIfPresent(BpmHandleFlowDO::getFlowStatus, reqVO.getFlowStatus())
                .betweenIfPresent(BpmHandleFlowDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(BpmHandleFlowDO::getUpdateTime, reqVO.getUpdateTime())
                .eqIfPresent(BpmHandleFlowDO::getCreator, reqVO.getCreator())
                .eqIfPresent(BpmHandleFlowDO::getUpdater, reqVO.getUpdater())
                .eqIfPresent(BpmHandleFlowDO::getDeleted, reqVO.getDeleted())
                .orderByDesc(BpmHandleFlowDO::getId));
    }

}
